package com.zxl.live.screen.screen.ui.helper.data;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.zxl.live.screen.R;
import com.zxl.live.screen.screen.constant.LockerEnv;
import com.zxl.live.screen.screen.ui.activity.SuiScreenDetailActivity;
import com.zxl.live.screen.ui.activity.MainActivity;
import com.zxl.live.screen.ui.fragment.ScreenFragment;
import com.zxl.live.tools.track.StatisticsType;

/**
 * Created by Administrator on 2018/1/9.
 */

public class SuiScreenDataHelper {

    public enum DataType {

        SUI(R.string.sui_screen_add_to_window_tips, 12, StatisticsType.SUI_SCREEN),

        KUONGBU(R.string.kuongbu_screen_add_to_window_tips, 6, StatisticsType.KONGBU),

        SYSTEM_ERROR(R.string.system_error_screen_add_to_window_tips, 5, StatisticsType.SYSTEM_ERROR),

        ANIMATION(R.string.animation_screen_add_to_window_tips, 7, StatisticsType.ANIMATION);

        private int tips;

        private int size;

        private StatisticsType type;

        DataType(int tips, int size, StatisticsType type) {
            this.tips = tips;
            this.size = size;
            this.type = type;
        }

        public int getTips() {
            return tips;
        }

        public int getSize() {
            return size;
        }

        public void restartPage(Activity activity, int position) {
            Intent[] intents = new Intent[2];
            intents[0] = new Intent(activity, MainActivity.class).putExtra("position", getIndex());
            intents[1] = new Intent(activity, SuiScreenDetailActivity.class).putExtra("position", position).putExtra("mDataType", this);
            activity.startActivities(intents);
            activity.finish();
        }

        public int getIndex() {
            ScreenFragment.ScreenData[] values = ScreenFragment.ScreenData.values();
            for (int i = 0; i < values.length; i++) {
                if (values[i].getType() == this) {
                    return i;
                }
            }
            return 0;
        }

        public void upload(Context context, String key, String value) {
            type.upload(context, key, value);
        }
    }
    public static String getMinImage(DataType dataType, int position) {
        if (dataType == DataType.KUONGBU) {
            return String.format("http://ovwluglb8.bkt.clouddn.com/screen/guitu%s.png", position + 1);
        } else if (dataType == DataType.SUI) {
            return String.format("http://ovwluglb8.bkt.clouddn.com/screen/smallcrack%s.png", position + 1);
        } else if (dataType == DataType.SYSTEM_ERROR) {
            switch (position) {
                case 0:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222102621531.png";
                case 1:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222136941751.png";
                case 2:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222159161801.png";
                case 3:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222214629720.png";
                case 4:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222228698688.png";
            }
        } else if (dataType == DataType.ANIMATION) {
            switch (position) {
                case 0:
                    return "http://ovwluglb8.bkt.clouddn.com/ccat.png";
                case 1:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318693192383.png";
                case 2:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318885915474.png";
                case 3:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318850662975.png";
                case 4:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318822077301.png";
                case 5:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318797989093.png";
                case 6:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318731755227.png";
            }
        }
        return "";
    }

    public static String getPreviewImage(DataType dataType, int position) {
        if (dataType == DataType.KUONGBU) {
            return String.format("http://ovwluglb8.bkt.clouddn.com/screen/midguitu%s.png", position + 1);
        } else if (dataType == DataType.SUI) {
            return String.format("http://ovwluglb8.bkt.clouddn.com/screen/midcrack%s.png", position + 1);
        } else if (dataType == DataType.SYSTEM_ERROR) {
            switch (position) {
                case 0:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222097778247.png";
                case 1:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222132329450.png";
                case 2:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222159161801.png";
                case 3:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222212419415.png";
                case 4:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222226792177.png";
            }
        } else if (dataType == DataType.ANIMATION) {
            switch (position) {
                case 0:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318971357319.png";
                case 1:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318687406497.png";
                case 2:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318879473355.png";
                case 3:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318841634050.png";
                case 4:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318815409737.png";
                case 5:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318790491328.png";
                case 6:
                    return "http://ovwluglb8.bkt.clouddn.com/1513318720013236.png";
            }
        }
        return "";
    }

    public static String getMaxImage(DataType dataType, int position) {
        if (dataType == DataType.KUONGBU) {
            return String.format("http://ovwluglb8.bkt.clouddn.com/screen/maxguitu%s.png", position + 1);
        } else if (dataType == DataType.SUI) {
            return String.format("http://ovwluglb8.bkt.clouddn.com/screen/maxcrack%s.png", position + 1);
        } else if (dataType == DataType.SYSTEM_ERROR) {
            switch (position) {
                case 2:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222148646366.png";
                case 3:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222209498173.png";
                case 4:
                    return "http://ovwluglb8.bkt.clouddn.com/1513222224296667.png";
            }
        } else if (dataType == DataType.ANIMATION) {
            switch (position) {
                case 0:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/newcat.zip?attname";
                case 1:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/tuzis.zip?attname";
                case 2:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/newgecko.zip?attname";
                case 3:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/butterfly.zip?attname";
                case 4:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/konglong.zip?attname";
                case 5:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/qingwamax.zip?attname";
                case 6:
                    return "http://ovwluglb8.bkt.clouddn.com/screen/xiyiyellow.zip?attname";
            }
        }
        return "";
    }

    public static String getMaxImagePath(DataType dataType, int position) {
        return LockerEnv.Path.SUI_SCREEN + getMaxImage(dataType, position).hashCode();
    }
}
